layui.define(['layer'], function (exports) {
    let $ = layui.jquery,
        layer = layui.layer;

    let $request = {
        post: function (url, data, successCallBack) {
            $.ajax({
                type: "post",
                url: url,
                dataTpe: "json",
                contentType: "application/json;charset=UTF-8",
                data: JSON.stringify(data),
                success: function (res) {
                    if (res.code === 20000) {
                        layer.msg(res.msg, {icon: 1});
                        typeof successCallBack === 'function' && successCallBack(res.data);
                    } else {
                        layer.msg(res.msg, {icon: 5});
                    }
                }
            })
        },
        get: function (url, successCallBack) {
            $.ajax({
                type: "get",
                contentType: "application/json;charset=UTF-8",
                dataTpe: "json",
                url: url,
                success: function (res) {
                    if (res.code === 50000) {
                        layer.msg(res.msg, {icon: 5});
                    }
                    typeof successCallBack === 'function' && successCallBack(res.data);
                }
            })
        }
    };
    exports('request', $request);
});

